package database;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import objects.WorldObject;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.Proxy;

import constants.Constants;

@Entity
@Table(name = "t_object")
@Proxy(lazy = false)
public class MWorldObject {

  private int id;
  private int objectRefName;
  private String name;
  private int x;
  private int y;
  private int type;
  private int owner= Constants.NO_OWNER;
  private int isActive = Constants.TRUE;
  private int activate = Constants.TRUE;
  private MWorldObject objectReference;
  private MWorld worldReference;
  private List<MAgent> agentList = new ArrayList<MAgent>();
  private List<MAction> actionList = new ArrayList<MAction>();
  private List<MSpecialFeature> specialFeatureList = new ArrayList<MSpecialFeature>();
  private List<MWorldObject> objectList = new ArrayList<MWorldObject>();

  // ----------------------------------------

  
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }
  
  // ----------------------------------------

	public String getName() {
	    return name;
	  }
	
	public void setName(String name) {
	    this.name = name;
	  }

	public int getX() {
		return x;
	}
	
	public void setX(int x) {
		this.x = x;
	}
	
	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}
	
	public int getType() {
		return type;
	}
	
	public void setType(int type) {
		this.type = type;
	}
	
	public int getOwner() {
		return owner;
	}
	
	public void setOwner(int owner) {
		this.owner = owner;
	}

	@OneToMany(mappedBy = "objectReference", orphanRemoval=true )
	@LazyCollection(LazyCollectionOption.TRUE)
	@Cascade({org.hibernate.annotations.CascadeType.ALL})
	public List<MAgent> getAgentList() {
		return agentList;
	}

	public void setAgentList(List<MAgent> agentList) {
		this.agentList = agentList;
	}

	@OneToMany(mappedBy = "objectReference", orphanRemoval=true )
	@LazyCollection(LazyCollectionOption.TRUE)
	@Cascade({org.hibernate.annotations.CascadeType.ALL})
	public List<MAction> getActionList() {
		return actionList;
	}

	public void setActionList(List<MAction> actionList) {
		this.actionList = actionList;
	}

	@OneToMany(mappedBy = "objectReference", orphanRemoval=true )
	@LazyCollection(LazyCollectionOption.TRUE)
	@Cascade({org.hibernate.annotations.CascadeType.ALL})
	public List<MSpecialFeature> getSpecialFeatureList() {
		return specialFeatureList;
	}

	public void setSpecialFeatureList(List<MSpecialFeature> specialFeatureList) {
		this.specialFeatureList = specialFeatureList;
	}

	@ManyToOne
	public MWorldObject getObjectReference() {
		return objectReference;
	}

	public void setObjectReference(MWorldObject objectReference) {
		this.objectReference = objectReference;
	}

	@OneToMany(mappedBy = "objectReference", orphanRemoval=true )
	@LazyCollection(LazyCollectionOption.TRUE)
	@Cascade({org.hibernate.annotations.CascadeType.ALL})
	public List<MWorldObject> getObjectList() {
		return objectList;
	}

	public void setObjectList(List<MWorldObject> objectList) {
		this.objectList = objectList;
	}

	@ManyToOne
	public MWorld getWorldReference() {
		return worldReference;
	}

	public void setWorldReference(MWorld worldReference) {
		this.worldReference = worldReference;
	}

	public int getObjectRefName() {
		return objectRefName;
	}

	public void setObjectRefName(int objectRefName) {
		this.objectRefName = objectRefName;
	}

	public int isActive() {
		return isActive;
	}

	public void setActive(int isActive) {
		this.isActive = isActive;
	}

	public int getActivate() {
		return activate;
	}

	public void setActivate(int activate) {
		this.activate = activate;
	}
	
	
	
  
}
